#!/bin/bash

#Panel for BigLinux
#
#Authors:
#  Bruno Goncalves Araujo <www.biglinux.com.br>
#
#License: GPLv2 or later
#################################################



. /usr/share/bigcontrolcenter/default/theme-categories.sh

#Translation
export TEXTDOMAINDIR="/usr/share/locale-langpack"
export TEXTDOMAIN=bigcontrolcenter 


echo '
<script language="JavaScript">
window.resizeTo(640,480);
function NoResize(){
  window.resizeTo(640,480);
}
</script>
'

tip_add=$"Crie novos usuarios."
tip_remove=$"Apague usuarios."
tip_perm=$"Escolha qual usuario sera administrador."
tip_pass=$"Altere a senha de qualquer usuario."
tip_time=$"Limite os horarios que cada usuario pode utilizar o computador."
tip_rest=$"Torne a configuracao de um usuario fixa, util para computadores de uso publico, por exemplo, em escolas."
title=$"Gerenciar usuarios"
apply=$"Aplicar"
close=$"Sair"

if [ "$(bigsudo-manager --check-privileges $p_username)" = "bigsudo" ]
then
  bigsudo_check="checked"
fi

if [ "$(bigsudo-manager --check-privileges $p_username)" = "admin" ]
then
  admin_check="checked"
fi

if [ "$(bigsudo-manager --check-privileges $p_username)" = "no" ]
then
  no_check="checked"
fi

#title
echo "<title>$title</title><body onResize=\"NoResize();\">"

#header
open_header
echo "$title" '</font><br>' $"Criar, remover e editar usuarios."
close_header


#Exibir resposta para o usuario
echo '<center><table width=95%><tr><td>'
echo '<p>'

echo "<center><table><tr><td><input type=radio name=escolha id=e0 value=texto onClick=\"Hide('div-avancado', this); Reveal('div-basico', this);\" checked><label for=e0>" $"Configuracao basica." "</label>"

echo "</td><td width=50></td><td><input type=radio name=escolha id=e1 value=texto onClick=\"Reveal('div-avancado', this); Hide('div-basico', this);\" ><label for=e1>" $"Configuracao avancada." "</label></center></td></tr></table><p><br>"


echo '<div id="div-basico">'
echo '<center><table width=70%><br>'
echo '<tr><td><a href="add.sh"'" $mouseover_open $tip_add $mouseover_close"'><img src="add.png"></td><td><a href="add.sh"'" $mouseover_open $tip_add $mouseover_close"'>' $"Adicionar usuario" '</a>'
echo '</td><td><P STYLE="margin:2px; margin-left:0px;"><a href="remove.sh"'" $mouseover_open $tip_remove $mouseover_close"'><img src="remove.png"></td><td><a href="remove.sh"'" $mouseover_open $tip_remove $mouseover_close"'>' $"Remover usuario" '</a>'
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="permission.sh"'" $mouseover_open $tip_perm $mouseover_close"'><img src="permission.png"></td><td><a href="permission.sh"'" $mouseover_open $tip_perm $mouseover_close"'>' $"Alterar permissoes" '</a>'
echo '</td><td><P STYLE="margin:2px; margin-left:0px;"><a href="password.sh"'" $mouseover_open $tip_pass $mouseover_close"'><img src="password.png"></td><td><a href="password.sh"'" $mouseover_open $tip_pass $mouseover_close"'>' $"Trocar senha" '</a>'
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="time.sh"'" $mouseover_open $tip_time $mouseover_close"'><img src="time.png"></td><td><a href="time.sh"'" $mouseover_open $tip_time $mouseover_close"'>' $"Limitar tempo de uso" '</a>'
echo '</td><td><P STYLE="margin:2px; margin-left:0px;"><a href="restore.sh"'" $mouseover_open $tip_rest $mouseover_close"'><img src="restore.png"></td><td><a href="restore.sh"'" $mouseover_open $tip_rest $mouseover_close"'>' $"Fixar configuracao" '</a>'
echo '</table></center>'
echo '</div>'

echo '<div id="div-avancado" style="display:none">'
echo '<center><table width=70%> <tr><td>'
if [ -e /usr/bin/users-admin ]
then
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="/usr/share/bigbashview/run.run?su -c users-admin"><img src="users-admin.png"></td><td><a href="/usr/share/bigbashview/run.run?su -c users-admin">' $"Editar usuarios utilizando Users Admin" '</a>'
fi

if [ -e /usr/bin/kuser ]
then
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="/usr/share/bigbashview/run.run?kuser"><img src="kuser.png"></td><td><a href="/usr/share/bigbashview/run.run?kuser">' $"Editar usuarios utilizando Kuser" '</a>'
fi

if [ -e /usr/bin/polkit-gnome-authorization ]
then
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="/usr/share/bigbashview/run.run?polkit-gnome-authorization"><img src="polkit.png"></td><td><a href="/usr/share/bigbashview/run.run?polkit-gnome-authorization">' $"Gerenciar permissoes utilizando PolicyKit Gnome" '</a>'
fi

if [ -e /usr/bin/polkit-kde-authorization ]
then
echo '</td></tr><tr><td><P STYLE="margin:2px; margin-left:0px;"><a href="/usr/share/bigbashview/run.run?polkit-kde-authorization"><img src="polkit2.png"></td><td><a href="/usr/share/bigbashview/run.run?polkit-kde-authorization">' $"Gerenciar permissoes utilizando PolicyKit KDE" '</a>'
fi
echo '</table></center>'
echo '</div>'


echo '</table></center>'
echo '</td></tr></table></center>'

echo "</div><div id=\"rodape\"><button type=submit id=\"signupsubmit\" value= $apply  >   <img src=\"/usr/share/bigcontrolcenter/default/images/ok.png\" style=\"vertical-align:top\" />  $apply   </button>  <button type=button value= $close onClick= parent.location='/usr/share/bigbashview/exemplo2.sh?close=True'>   <img src=\"/usr/share/bigcontrolcenter/default/images/cancel.png\" style=\"vertical-align:top\"  />  $close     </button></div>"
